home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / incl / LEDA / queue.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.4 KB  |  53 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  queue.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_QUEUE_H
  16. #define LEDA_QUEUE_H
  17.  
  18. //------------------------------------------------------------------------------
  19. // queue                                                                
  20. //------------------------------------------------------------------------------
  21.  
  22. #include <LEDA/basic.h>
  23. #include <LEDA/impl/slist.h>
  24.  
  25.  
  26.  
  27. template<class type>
  28.  
  29. class _CLASSTYPE queue : private SLIST
  30. {
  31.   void copy_el(GenPtr& x)  const { x=Copy(ACCESS(type,x)); }
  32.   void clear_el(GenPtr& x) const { Clear(ACCESS(type,x)); }
  33.  
  34. public:
  35.  
  36.   queue() {}
  37.   queue(const queue<type>& Q) : SLIST(Q) {}
  38.  ~queue() { clear(); }
  39.  
  40.   void append(type x) { SLIST::append(Copy(x)); }
  41.   type top()   const  { return ACCESS(type,SLIST::head()); }
  42.   type pop()          { type x=top(); SLIST::pop(); return x; }
  43.   int  size()  const  { return SLIST::length(); }
  44.   int  empty() const  { return SLIST::empty(); }
  45.   void clear()        { SLIST::clear(); }
  46.  
  47.   queue<type>& operator=(const queue<type>& Q) 
  48.                       { return (queue<type>&)SLIST::operator=(Q); }
  49. };
  50.  
  51. #endif
  52.